package com.chb.service.impl;

import com.chb.dao.OutStaffDao;
import com.chb.model.entity.QuitStaff;
import com.chb.model.entity.Staff;
import com.chb.model.vo.QuitStaffVo;
import com.chb.model.vo.Result;
import com.chb.service.QuitStaffService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author ：张家琪
 * @date ：Created in 2023/10/11 9:44
 * @description：
 * @modified By：
 * @version:
 */
@Service
public class QuitStaffServiceImpl implements QuitStaffService {
    @Autowired
    private OutStaffDao outStaffDao;
    @Autowired
    private HttpSession session;

    @Override
    public Result findAll(Integer current, Integer pageSize, QuitStaffVo outStaffVo) {
        Staff staff = (Staff) session.getAttribute("staff");
        PageHelper.startPage(current, pageSize);
        if (staff.getStaffid() != 111) {
            outStaffVo.setBranchid(staff.getBranchid());
        }
        List<QuitStaff> list = outStaffDao.findAll(outStaffVo);
        PageInfo<QuitStaff> pageInfo = new PageInfo<QuitStaff>(list);
        return new Result(200, "查询成功", pageInfo);
    }
}